home *** CD-ROM | disk | FTP | other *** search
- Path: tech.cftnet.com!not-for-mail
- From: wcowley@cftnet.com (Wes Cowley)
- Newsgroups: comp.lang.c++
- Subject: Re: Any way to restrict casting?
- Date: 22 Feb 1996 11:19:30 GMT
- Organization: CFTnet
- Message-ID: <4ghjg2$1po@tech.cftnet.com>
- References: <4gfuj4$1cu@news.mistral.co.uk>
- NNTP-Posting-Host: ppp244_8.cftnet.com
- X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]
-
- Alan Campbell (alanc@mistral.co.uk) wrote:
- : Using Borland C++ 3.1, I find I can coerce a pointer to an instance of
- : a class into a pointer to *anything*. Like an int.
- :
- : [ code cut ]
- :
- : Is this valid in all dialects of C++? Is it part of the standard? If
- : so, ouch.
-
- It's valid. If you use a cast you're telling the compiler that you're
- taking responsibility for the type system violation. If you cast to
- something that doesn't make sense, the compiler's not going to stop you
- because you've told it, via the cast, that you know what you're doing.
-
- Wes
-